#!/usr/bin/env php
<?php

# A client that runs 10 'work' tasks one at a time.

$begin = gettimeofday(true);

$client= new GearmanClient();
$client->addServer('127.0.0.1', 4730);

$results = array();
for ($x = 0; $x < 10; $x++)
{
  $results[$x]['data'] = $client->do('work', "$x");
  $results[$x]['handle'] = $client->doJobHandle();
}

printf("Jobs ran in %.6f seconds.\n",
       gettimeofday(true) - $begin);

for ($x = 0; $x < 10; $x++)
{
  print $results[$x]['handle'] . '=';
  print $results[$x]['data'] . "\n";
}

?>
